package com.wiloon.java8x.io.file;

import java.io.BufferedReader;
import java.io.FileNotFoundException;
import java.io.FileReader;
import java.io.IOException;

/**
 * Created with IntelliJ IDEA.
 * User: wiloon
 * Date: 9/2/12
 * Time: 12:20 PM
 */
public class TextFileReader {

    public String read(String path) {
        StringBuffer sb = new StringBuffer();
        FileReader reader = null;
        try {
            reader = new FileReader(path);
            BufferedReader br = new BufferedReader(reader);
            String s1 = null;
            while ((s1 = br.readLine()) != null) {
                sb.append(s1);
            }
            br.close();
            reader.close();
        } catch (FileNotFoundException e) {
            e.printStackTrace();  //To change body of catch statement use File | Settings | File Templates.
        } catch (IOException e) {
            e.printStackTrace();  //To change body of catch statement use File | Settings | File Templates.
        }

        return sb.toString();
    }

    public static void main(String[] args) throws Exception {
        TextFileReader tfr = new TextFileReader();
        String content = tfr.read("/home/wiloon/tmp/rssLab/infozm80260.html");
        System.out.println(content);
    }
}
